package com.ymatou.iapi.payment.testcase;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.payment.parameter.AcquireOrderBean;
import com.ymatou.iapi.payment.parameter.AcquireRefundBean;
import com.ymatou.iapi.payment.parameter.ExecuteRefundBean;
import com.ymatou.iapi.payment.parameter.FastRefundBean;
import com.ymatou.iapi.payment.service.ExecuteRefundCall;
import com.ymatou.paygetway.parameter.ApplePayRefundNotifyBean;
import com.ymatou.paygetway.parameter.BaoFuRefundNotifyBean;
import com.ymatou.paygetway.serivce.RefundNotifyCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P2;
import com.ymt.utils.tag.P3;
import com.ymttest.business.service.AccountCallServiceV2;
import com.ymttest.business.service.PayGateWayCallService;
import com.ymttest.database.model.Account;
import com.ymttest.database.model.AccountEntry;
import com.ymttest.database.model.MPayment;
import com.ymttest.database.model.MRefund;
import com.ymttest.database.sqlwapper.AccountWapper;
import com.ymttest.database.sqlwapper.PayGateWayWapper;
import com.ymttest.utils.BaofooSignature;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;

/**
 * 退款执行 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_ExecuteRefund {
	private static ExecuteRefundBean executerefundBean;
	private static ExecuteRefundCall executerefundCall;
	private static PayGateWayWapper pdw;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("退款执行");
	}

	@Before
	public void caseUp() {
		executerefundBean = new ExecuteRefundBean();
		executerefundCall = new ExecuteRefundCall();
		pdw = new PayGateWayWapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(executerefundCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	private MPayment getPPPayment(AcquireOrderBean aqb) {

		MPayment ppm = new MPayment();
		try {
			ppm = pdw.selectPaymentByTradingid(aqb.getOrderId()).get(0);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return ppm;
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_001() {
		Logger.start(true, "退款状态为0初始化审核状态为1审核通过,执行退款修改退款状态1");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "0");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			// 异步 返回不验证
			// Logger.verifyEquals("1", executerefundCall.getReturnData(),
			// "验证返回结果");

			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(1, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus1");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_002() {
		Logger.start(false, "退款状态为0初始化审核状态为1审核通过,提交第三方退款失败-1");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "0");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.callService();

			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-1, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	@Ignore
	// 未审核不会生成退款单号，缺少必填项，此case场景不存在
	public void Tc_ExecuteRefund_003() {
		Logger.start(true, "退款状态为0初始化审核状态为0未审核,不执行状态依然是0初始化");
		try {

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_004() {
		Logger.start(true, "退款状态为0初始化审核状态为9快速退款,执行退款修改退款状态1,扣除码头账户余额验证账务日志PP_AccoutingLog");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			// AcquireRefundBean ar =
			// PayGateWayCallService.AcquireRefund(aqb,aqb.getPayPrice());
			// PayGateWayCallService.approveRefund(ar.getTradeNo());
			FastRefundBean fastrefundBean = PayGateWayCallService.fastRefund(aqb);
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "0");
			List<MRefund> rrlist = pdw.selectRefundRequestByTraceId(mrr.getRequestId().toString());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			// Logger.verifyEquals("1", executerefundCall.getReturnData(),
			// "验证返回结果");

			rrlist = pdw.selectRefundRequestByTraceId(mrr.getRequestId().toString());
			Logger.verifyEquals(1, rrlist.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus1");
			Logger.comment("验证数据表PP_AccoutingLog");
			List<Map> list = pdw.selectPPAccoutingLogByBizno(mrr.getRefundId().toString());
			Logger.verifyEquals(true, list.size() >= 1, "验证PP_AccoutingLog表中有记录");
			if (list.size() > 0) {
				Map maccountlog = list.get(0);
				// {AccountingType=Refund, Status=1, RespCode=0, RespMsg=操作成功！,
				// CreatedTime=2016-06-21 16:56:20.807, AccoutingAmt=3.00,
				// UserId=2837880, BizNo=201606210000001433, Id=41, Memo=快速退款}
				Logger.verifyEquals("Refund", maccountlog.get("AccountingType").toString(), "验证PP_AccoutingLog表中AccountingType字段");
				// 快速退款申请成功状态1？待确认
				Logger.verifyEquals("1", maccountlog.get("Status").toString(), "验证PP_AccoutingLog表中Status字段");
				// Logger.verifyEquals("0",
				// maccountlog.get("RespCode").toString(),
				// "验证PP_AccoutingLog表中RespCode字段");
				// Logger.verifyEquals("操作成功！",
				// maccountlog.get("RespMsg").toString(),
				// "验证PP_AccoutingLog表中RespMsg字段");
				if (fastrefundBean.getRefundAmt() != null) {
					Logger.verifyEquals(new Double(fastrefundBean.getRefundAmt()), new Double(maccountlog.get("AccoutingAmt").toString()), "验证PP_AccoutingLog表中AccoutingAmt字段");
				} else {
					Logger.verifyEquals(new Double(aqb.getPayPrice()), new Double(maccountlog.get("AccoutingAmt").toString()), "验证PP_AccoutingLog表中AccoutingAmt字段");
				}
				Logger.verifyEquals(aqb.getUserId(), maccountlog.get("UserId").toString(), "验证PP_AccoutingLog表中UserId字段");
				// Logger.verifyEquals("快速退款",
				// maccountlog.get("Memo").toString(),
				// "验证PP_AccoutingLog表中Memo字段");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_005() {
		Logger.start(false, "退款状态为0初始化审核状态为9快速退款,扣除码头账户余额失败0");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "0");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			// TODO 提交前更新码头账户余额为0
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			// 异步 返回不验证
			// Logger.verifyEquals("1", executerefundCall.getReturnData(),
			// "验证返回结果");

			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(1, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus1");
			// TODO 提交后再更新码头账户余额为一个大金额
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_006() {
		Logger.start(false, "退款状态为0初始化审核状态为9快速退款,提交第三方退款失败-1");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			// AcquireRefundBean ar =
			// PayGateWayCallService.AcquireRefund(aqb,aqb.getPayPrice());
			// PayGateWayCallService.approveRefund(ar.getTradeNo());
			FastRefundBean fastrefundBean = PayGateWayCallService.fastRefund(aqb);
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			List<MRefund> rrlist = pdw.selectRefundRequestByTraceId(mrr.getRequestId().toString());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^FAILED");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-1", executerefundCall.getReturnData(), "验证返回结果");
			List<MRefund> list = pdw.selectRefundRequestByRefundId(refundid);
			Logger.verifyEquals(-1, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P3.class })
	@TestCase
	public void Tc_ExecuteRefund_007() {
		Logger.start(false, "输入不存在的单号，失败");
		try {
			executerefundBean.setRefundId("-1");
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			// String
			// mockResult=FormatUtil.urlEncode("is_success=T&result_details="+refundbn+"^"+ppm.getInstitutionPaymentId()+"^"+aqb.getPayPrice()+"^SUCCESS");
			// executerefundCall.addHeader("MockResult-AliPay-Result",mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			// TODO 输入不存在的会发生什么?现在没有错误返回
			Logger.verifyEquals("ok", executerefundCall.getReturnData(), "验证返回结果");
			//
			// list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			// Logger.verifyEquals(1, list.get(0).getRefundStatus(),
			// "提交第三方退款成功RefundStatus1");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P3.class })
	@TestCase
	public void Tc_ExecuteRefund_008() {
		Logger.start(false, "不输入单号，失败");
		try {
			executerefundBean.setRefundId("");
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("1000", executerefundCall.getReturnData(), "验证返回结果");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_009() {
		Logger.start(true, "支付宝退款状态为1提交Mock,is_success=T,返回位数4,处理结果码success,更改退款状态为3退款完成");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");

			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_010() {
		Logger.start(false, "支付宝退款状态为1提交Mock,is_success=T,返回位数4,处理结果码failed更改退款状态为-1退款失败");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^FAILED");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-1", executerefundCall.getReturnData(), "验证返回结果");

			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-1, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus-1");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_011() {
		Logger.start(true, "支付宝退款状态为3提交Mock,交易网关成功,更改退款状态为4完全完成");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "3");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			executerefundCall.addHeader("MockResult-Trading-Status", "OK");
			executerefundCall.addHeader("MockResult-Trading-Body", "{\"code\":200}");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("4", executerefundCall.getReturnData(), "验证返回结果");

			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(4, list.get(0).getRefundStatus(), "交易网关返回退款成功RefundStatus4");
			executerefundCall.callService();
			Logger.verifyEquals("ok", executerefundCall.getReturnData(), "再次执行验证返回结果ok");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_012() {
		Logger.start(false, "支付宝退款状态为3提交Mock,交易网关失败,通知交易系统失败");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "3");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-Trading-Body", "{\"code\":500}");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");

			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "交易网关返回退款失败RefundStatus");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_013() {
		Logger.start(false, "支付宝退款状态为1提交Mock,第三方金额错误,更改退款状态为-2完全失败");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + 1 + aqb.getPayPrice() + "^SUCCESS");
			Logger.debug(mockResult);
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-2", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-2, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus-2");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_014() {
		Logger.start(false, "支付宝退款状态为1提交Mock,报文没有明细信息,更改退款状态为-2完全失败");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T");
			Logger.debug(mockResult);
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-2", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-2, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus-2");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_015() {
		Logger.start(false, "支付宝退款状态为1提交Mock,报文InstitutionPaymentId不正确,更改退款状态为-2完全失败");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil
					.urlEncode("is_success=T&result_details=" + refundbn + "^" + 1 + ppm.getInstitutionPaymentId() + "^" + 1 + aqb.getPayPrice() + "^SUCCESS");
			Logger.debug(mockResult);
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-2", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-2, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus-2");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_016() {
		Logger.start(true, "支付宝退款状态为1提交Mock,is_success=T,返回位数6,处理结果码success,是否充退false,充退结果null,更改退款状态为3退款完成");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil
					.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS^false^null");
			Logger.debug(mockResult);
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus3");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_017() {
		Logger.start(false, "支付宝退款状态为1提交Mock,is_success=T,返回位数6,处理结果码failed是否充退false,充退结果null,更改退款状态为-1退款失败");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil
					.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^FAILED^false^null");
			Logger.debug(mockResult);
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-1", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-1, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus3");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_018() {
		Logger.start(true, "支付宝退款状态为1提交Mock,is_success=T,返回位数6,处理结果码success是否充退true充退结果S更改退款状态为3退款完成");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS^true^S");
			Logger.debug(mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus3");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_019() {
		Logger.start(true, "支付宝退款状态为1提交Mock,is_success=T,返回位数6,处理结果码success是否充退true充退结果P更改退款状态为2退款中");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS^true^P");
			Logger.debug(mockResult);
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("2", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(2, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus2");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_020() {
		Logger.start(true, "支付宝退款状态为1提交Mock,is_success=T,返回位数6,处理结果码success是否充退true充退结果F更改退款状态为3退款完成(退到支付宝余额)");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS^true^F");
			Logger.debug(mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus3");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_021() {
		Logger.start(false, "支付宝退款状态为1提交Mock,is_success=T,返回位数6,处理结果码success是否充退true充退结果null更改退款状态为-1退款失败");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil
					.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS^true^null");
			Logger.debug(mockResult);
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-1", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-1, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus-1");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_022() {
		Logger.start(true, "支付宝退款状态为2提交Mock,is_success=T,返回位数6,处理结果码success是否充退true充退结果S更改退款状态为3退款完成");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "2");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS^true^S");
			Logger.debug(mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus3");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_023() {
		Logger.start(true, "支付宝退款状态为2提交Mock,is_success=T,返回位数6,处理结果码success是否充退true充退结果P更改退款状态为2退款中(不变)");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "2");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS^true^P");
			Logger.debug(mockResult);
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("2", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(2, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus2");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_024() {
		Logger.start(true, "支付宝退款状态为2提交Mock,is_success=T,返回位数6,处理结果码success是否充退true充退结果F更改退款状态为3退款完成");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "2");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS^true^F");
			Logger.debug(mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus3");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_025() {
		Logger.start(false, "支付宝退款状态为2提交Mock,is_success=T,返回位数6,处理结果码success是否充退true充退结果null更改退款状态为-1退款失败");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "2");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil
					.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS^true^null");
			Logger.debug(mockResult);
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-1", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-1, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus-1");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_026() {
		Logger.start(true, "支付宝退款状态为1提交Mock,is_success=F,ErrorCode为Refund_not_exist,更改退款状态为0初始化");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=F&error_code=REFUND_NOT_EXIST");
			Logger.debug(mockResult);
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("0", executerefundCall.getReturnData(), "验证返回结果");

			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(0, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus0");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_027() {
		Logger.start(false, "支付宝退款状态为1提交Mock,is_success=F,ErrorCode为other,更改退款状态为-1退款失败");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=F&error_code=other");
			Logger.debug(mockResult);
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-1", executerefundCall.getReturnData(), "验证返回结果");

			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-1, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus0");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_028() {
		Logger.start(true, "支付宝退款状态为-1提交Mock,is_success=T,返回位数4,处理结果码success,更改退款状态为3退款完成");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "-1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS");
			Logger.debug(mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus-1");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_029() {
		Logger.start(false, "支付宝退款状态为-1提交Mock,is_success=T,返回位数4,处理结果码failed更改退款状态为-1退款失败");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "-1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^FAILED");
			Logger.debug(mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-1", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-1, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus-1");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_030() {
		Logger.start(true, "支付宝退款状态为-1提交Mock,is_success=T,返回位数6,处理结果码success,是否充退false,充退结果null,更改退款状态为3退款完成");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "-1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil
					.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS^false^null");
			Logger.debug(mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus-1");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_031() {
		Logger.start(false, "支付宝退款状态为-1提交Mock,is_success=T,返回位数6,处理结果码failed是否充退false,充退结果null,更改退款状态为-1退款失败");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "-1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil
					.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^FAILED^false^null");
			Logger.debug(mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-1", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-1, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus-1");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_032() {
		Logger.start(true, "支付宝退款状态为-1提交Mock,is_success=T,返回位数6,处理结果码success是否充退true充退结果S更改退款状态为3退款完成");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "-1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS^true^S");
			Logger.debug(mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus-1");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_033() {
		Logger.start(true, "支付宝退款状态为-1提交Mock,is_success=T,返回位数6,处理结果码success是否充退true充退结果P更改退款状态为2退款中");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "-1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS^true^P");
			Logger.debug(mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("2", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(2, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus-1");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_034() {
		Logger.start(true, "支付宝退款状态为-1提交Mock,is_success=T,返回位数6,处理结果码success是否充退true充退结果F更改退款状态为3退款完成(退到支付宝余额)");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "-1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS^true^F");
			Logger.debug(mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus-1");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_035() {
		Logger.start(false, "支付宝退款状态为-1提交Mock,is_success=T,返回位数6,处理结果码success是否充退true充退结果null更改退款状态为-1退款失败");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "-1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil
					.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS^true^null");
			Logger.debug(mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-1", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-1, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus-1");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_036() {
		Logger.start(true, "微信退款状态为1提交Mock,refund_status为SUCCESS,更改退款状态为3退款完成");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-refund_status", "SUCCESS");
			executerefundCall.addHeader("MockResult-WeiXin-total_fee", new BigDecimal(aqb.getPayPrice()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-refund_fee", new BigDecimal(ar.getRefundAmt()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-out_trade_no",ppm.getPaymentId());
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus3");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_037() {
		Logger.start(false, "微信退款状态为1提交Mock,refund_status为CHANGE更改退款状态为-2完全失败");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-refund_status", "CHANGE");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-2", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-2, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus3");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_038() {
		Logger.start(true, "微信退款状态为1提交Mock,refund_status为PROCESSING更改退款状态为2退款中");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-refund_status", "PROCESSING");
			executerefundCall.addHeader("MockResult-WeiXin-total_fee", new BigDecimal(aqb.getPayPrice()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-refund_fee", new BigDecimal(ar.getRefundAmt()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-out_trade_no",ppm.getPaymentId());
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("2", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(2, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus3");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_039() {
		Logger.start(true, "微信退款状态为1提交Mock,refund_status为NOTSURE更改退款状态为0初始化后");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-refund_status", "NOTSURE");
			executerefundCall.addHeader("MockResult-WeiXin-total_fee", new BigDecimal(aqb.getPayPrice()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-refund_fee", new BigDecimal(ar.getRefundAmt()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-out_trade_no",ppm.getPaymentId());
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("0", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(0, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus0");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_040() {
		Logger.start(false, "微信退款状态为1提交Mock,refund_status为FAIL更改退款状态为-1退款失败");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-refund_status", "FAIL");
			executerefundCall.addHeader("MockResult-WeiXin-total_fee", new BigDecimal(aqb.getPayPrice()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-refund_fee", new BigDecimal(ar.getRefundAmt()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-out_trade_no",ppm.getPaymentId());
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-1", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-1, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus-1");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_041() {
		Logger.start(true, "微信退款状态为-1提交Mock,refund_status为SUCCESS,更改退款状态为3退款完成");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "-1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-refund_status", "SUCCESS");
			executerefundCall.addHeader("MockResult-WeiXin-total_fee", new BigDecimal(aqb.getPayPrice()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-refund_fee", new BigDecimal(ar.getRefundAmt()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-out_trade_no",ppm.getPaymentId());
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus3");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_042() {
		Logger.start(false, "微信退款状态为-1提交Mock,refund_status为CHANGE更改退款状态为-2完全失败");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "-1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-refund_status", "CHANGE");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-2", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-2, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus-2");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_043() {
		Logger.start(true, "微信退款状态为-1提交Mock,refund_status为PROCESSING更改退款状态为2退款中");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "-1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-refund_status", "PROCESSING");
			executerefundCall.addHeader("MockResult-WeiXin-total_fee", new BigDecimal(aqb.getPayPrice()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-refund_fee", new BigDecimal(ar.getRefundAmt()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-out_trade_no",ppm.getPaymentId());
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("2", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(2, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus2");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_044() {
		Logger.start(true, "微信退款状态为-1提交Mock,refund_status为NOTSURE更改退款状态为0初始化后");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "-1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-refund_status", "NOTSURE");
			executerefundCall.addHeader("MockResult-WeiXin-total_fee", new BigDecimal(aqb.getPayPrice()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-refund_fee", new BigDecimal(ar.getRefundAmt()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-out_trade_no",ppm.getPaymentId());
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("0", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(0, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus0");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_045() {
		Logger.start(false, "微信退款状态为-1提交Mock,refund_status为FAIL更改退款状态为-1退款失败");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "-1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-refund_status", "FAIL");
			executerefundCall.addHeader("MockResult-WeiXin-total_fee", new BigDecimal(aqb.getPayPrice()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-refund_fee", new BigDecimal(ar.getRefundAmt()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-out_trade_no",ppm.getPaymentId());
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-1", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-1, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus-1");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_046() {
		Logger.start(true, "微信退款状态为2提交Mock,refund_status为SUCCESS,更改退款状态为3退款完成");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "-1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-refund_status", "SUCCESS");
			executerefundCall.addHeader("MockResult-WeiXin-total_fee", new BigDecimal(aqb.getPayPrice()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-refund_fee", new BigDecimal(ar.getRefundAmt()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-out_trade_no",ppm.getPaymentId());
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus3");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_047() {
		Logger.start(false, "微信退款状态为2提交Mock,refund_status为CHANGE更改退款状态为-2完全失败");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "2");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-refund_status", "CHANGE");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-2", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-2, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus-2");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_048() {
		Logger.start(true, "微信退款状态为2提交Mock,refund_status为PROCESSING更改退款状态为2退款中");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "2");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-refund_status", "PROCESSING");
			executerefundCall.addHeader("MockResult-WeiXin-total_fee", new BigDecimal(aqb.getPayPrice()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-refund_fee", new BigDecimal(ar.getRefundAmt()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-out_trade_no",ppm.getPaymentId());
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("2", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(2, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus2");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_049() {
		Logger.start(true, "微信退款状态为2提交Mock,refund_status为NOTSURE更改退款状态为0初始化后");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "2");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-refund_status", "NOTSURE");
			executerefundCall.addHeader("MockResult-WeiXin-total_fee", new BigDecimal(aqb.getPayPrice()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-refund_fee", new BigDecimal(ar.getRefundAmt()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-out_trade_no",ppm.getPaymentId());
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("0", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(0, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus0");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_050() {
		Logger.start(false, "微信退款状态为2提交Mock,refund_status为FAIL更改退款状态为-1退款失败");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "2");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-refund_status", "FAIL");
			executerefundCall.addHeader("MockResult-WeiXin-total_fee", new BigDecimal(aqb.getPayPrice()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-refund_fee", new BigDecimal(ar.getRefundAmt()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-out_trade_no",ppm.getPaymentId());
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-1", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-1, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus-1");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_051() {
		Logger.start(false, "订单作废softdelete=1退款,返回ok落库1");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			pdw.updateRefundSoftDeleteFlag(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.addHeader("MockResult-WeiXin-total_fee", new BigDecimal(aqb.getPayPrice()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-refund_fee", new BigDecimal(ar.getRefundAmt()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-out_trade_no",ppm.getPaymentId());
			executerefundCall.callService();
			Logger.verifyEquals("ok", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(1, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus1");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_052() {
		Logger.start(true, "微信退款paytype15状态为2提交Mock,refund_status为SUCCESS,更改退款状态为3退款完成");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("15");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "-1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-refund_status", "SUCCESS");
			executerefundCall.addHeader("MockResult-WeiXin-total_fee", new BigDecimal(aqb.getPayPrice()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-refund_fee", new BigDecimal(ar.getRefundAmt()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-out_trade_no",ppm.getPaymentId());
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus3");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_053() {
		Logger.start(true, "支付宝paytype13退款状态为1提交Mock,is_success=T,返回位数4,处理结果码success,更改退款状态为3退款完成");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("13");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");

			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_054() {
		Logger.start(true, "支付宝退款状态为4提交Mock,交易网关成功,更改退款状态为4完全完成(支付宝回调通知已经修改4成功后调度服务再调用执行的情况)");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "4");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			executerefundCall.addHeader("MockResult-Trading-Status", "OK");
			executerefundCall.addHeader("MockResult-Trading-Body", "Proccessed");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("ok", executerefundCall.getReturnData(), "验证返回结果");

			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(4, list.get(0).getRefundStatus(), "交易网关返回退款成功RefundStatus4");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_055() {
		Logger.start(true, "支付宝退款状态为3提交Mock,交易网关Proccessed成功(.net站点兼容),更改退款状态为4完全完成");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "3");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			executerefundCall.addHeader("MockResult-Trading-Status", "OK");
			executerefundCall.addHeader("MockResult-Trading-Body", "Proccessed");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("4", executerefundCall.getReturnData(), "验证返回结果");

			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(4, list.get(0).getRefundStatus(), "交易网关返回退款成功RefundStatus4");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_056() {
		Logger.start(false, "退款状态为0初始化审核状态为9快速退款,余额不足失败");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			aqb.setUserId("171");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			// 更新退款状态
			pdw.updateRefundStatus(refundbn, "0");
			pdw.updateRefundApproveStatus(refundbn, "9");

			// 更新余额
			Account account = new AccountWapper().selectAccountInfoByUserId(Integer.valueOf(aqb.getUserId())).get(0);
			Logger.comment("设置userid171账户资源余额不足");
			new AccountCallServiceV2().resetAccount(account.getAccountId().toString(), new BigDecimal(0), new BigDecimal(0));

			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			Logger.comment("设置交易返回成功");
			executerefundCall.addHeader("MockResult-Trading-Status", "ok");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("0", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());

			executerefundCall.callService();
			Logger.verifyEquals("ok", executerefundCall.getReturnData(), "验证第二次返回结果ok");
			Logger.verifyEquals(0, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus0");
			Logger.verifyEquals(true, list.get(0).getIsCancel(), "IsCancel true");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_057() {
		Logger.start(false, "支付宝退款状态为0初始化审核状态为1审核通过,提交第三方退款失败TRADE_HAS_CLOSED-2");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("13");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil
					.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^TRADE_HAS_CLOSED^false^null");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			Logger.comment("设置交易返回失败");
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-2", executerefundCall.getReturnData(), "验证返回结果");

			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-2, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_058() {
		Logger.start(true, "支付宝退款状态为1提交Mock,更改退款状态为3后调用notify");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus3");

			ppm = this.getPPPayment(aqb);
			int pstatus1 = ppm.getPayStatus();
			Thread.sleep(1000);
			PayGateWayCallService.notifyCall(aqb);
			ppm = this.getPPPayment(aqb);
			int pstatus2 = ppm.getPayStatus();
			Logger.verifyEquals(2, pstatus1, "验证支付状态为2");
			Logger.verifyEquals(pstatus2, pstatus1, "验证支付状态一致,不更新");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_059() {
		Logger.start(true, "微信退款paytype14状态为1提交Mock,MockResult-WeiXin-refund_count多笔,退款状态正常(RA-2623,原来会失败)");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "-1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-refund_status", "SUCCESS");
			executerefundCall.addHeader("MockResult-WeiXin-total_fee", new BigDecimal(aqb.getPayPrice()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-refund_fee", new BigDecimal(ar.getRefundAmt()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-out_trade_no",ppm.getPaymentId());
			executerefundCall.addHeader("MockResult-WeiXin-refund_count", "2");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus3");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_060() {
		Logger.start(true, "微信退款paytype14状态为1提交Mock,return_msg为System Error状态不变(RA-2623)");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-return_code", "FAIL");
			executerefundCall.addHeader("MockResult-WeiXin-return_msg", "System Error");

			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("1", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(1, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus不变");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_061() {
		Logger.start(true, "微信退款paytype14状态为1提交Mock,errorcode为SYSTEMERROR状态不变(JIRACONN-980)");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-WeiXin-err_code", "SYSTEMERROR");

			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("1", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(1, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus不变");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_062() {
		Logger.start(true, "微信退款paytype14状态为1提交Mock,errorcode为USER_ACCOUNT_ABNORMAL状态-2(JIRACONN-1274)");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			Account account = new AccountWapper().selectAccountInfoByUserId(Integer.valueOf(aqb.getUserId())).get(0);
			Logger.comment("设置userid账户余额");
			new AccountCallServiceV2().resetAccount(account.getAccountId().toString(), new BigDecimal(0), new BigDecimal(0));

			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-WeiXin-err_code", "USER_ACCOUNT_ABNORMAL");
			executerefundCall.addHeader("mockresult-weixin-result_code", "FAIL");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-3, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus");

			executerefundCall.callService();
			Thread.sleep(1000);
			Logger.verifyEquals("5", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(5, list.get(0).getRefundStatus(), "再次调用退到余额");

//			List<AccountEntry> alist = new AccountWapper().selectAccountEntryByOriginalNo(ar.getTradeNo());
			List<AccountEntry> alist = new AccountWapper().selectAccountEntryByOriginalNo(ar.getTradeNo());
			Logger.debug(FormatUtil.beanToGSONString(alist));
//			Logger.debug(FormatUtil.beanToGSONString(alist));
			Logger.verifyEquals(new BigDecimal(aqb.getPayPrice()).setScale(2), new BigDecimal(alist.get(0).getAvailAmount().toString()).setScale(2), "余额");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_063() {
		Logger.start(true, "招行退款paytype50状态为3提交Mock,成功状态4");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("50");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "3");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回成功");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("Mock", "1");
			executerefundCall.addHeader("MockResult-Trading-Status", "OK");
			executerefundCall.addHeader("MockResult-Trading-Body", "{\"code\":200}");

			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("4", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(4, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus不变");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_064() {
		Logger.start(true, "招行退款paytype50状态为0提交Mock,成功状态3,JIRACONN-5757");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("50");
			aqb.setPayPrice("6.00");
			PayGateWayCallService.acquireOrder(aqb);
			String discountAmt = "1.00";
			PayGateWayCallService.notifyCall50(aqb, discountAmt);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, "5.00");
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "0");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回成功");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Cmb-rspCode", "SUC0000");
			executerefundCall.addHeader("MockResult-Cmb-cardType", "02");
			executerefundCall.addHeader("MockResult-Cmb-orderAmount", "6.00");
			executerefundCall.addHeader("MockResult-Cmb-discountAmount", "0.00");
			executerefundCall.addHeader("MockResult-Cmb-orderStatus", "0");
			executerefundCall.addHeader("MockResult-Cmb-date", YMTDateUtil.getSysTime("yyyyMMdd"));
			executerefundCall.addHeader("MockResult-Cmb-orderNo", ppm.getPaymentId());

			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款成功");
			// pp_payment paystatus 2 CompleteRefundAmt 退款金额
			ppm = this.getPPPayment(aqb);
			Logger.verifyEquals(2, ppm.getPayStatus(), "验证PayStatus");
			Logger.verifyEquals(new BigDecimal(ar.getRefundAmt()), ppm.getCompletedRefundAmt(), "验证CompleteRefundAmt");
			Logger.verifyEquals(new BigDecimal(discountAmt), ppm.getDiscountAmt(), "验证DiscountAmt");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_065() {
		Logger.start(true, "微信PC退款状态为1提交Mock,refund_status为SUCCESS,更改退款状态为3退款完成");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("16");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-refund_status", "SUCCESS");
			executerefundCall.addHeader("MockResult-WeiXin-total_fee", new BigDecimal(aqb.getPayPrice()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-refund_fee", new BigDecimal(ar.getRefundAmt()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-out_trade_no",ppm.getPaymentId());
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus3");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_066() {
		Logger.start(false, "支付宝退款RefundStatus状态为1,ymt支付宝商家账户余额不足,RefundStatus状态回到0,JIRACONN-5757");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("13");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil
					.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SELLER_BALANCE_NOT_ENOUGH^false^null");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			Logger.comment("设置交易返回失败");
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("0", executerefundCall.getReturnData(), "验证返回结果");

			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(0, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_067() {
		Logger.start(true, "微信退款paytype14状态为0提交Mock,errorcode为USER_ACCOUNT_ABNORMAL状态0(JIRACONN-9381)");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("14");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "0");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-WeiXin-err_code", "USER_ACCOUNT_ABNORMAL");
			executerefundCall.addHeader("mockresult-weixin-result_code", "FAIL");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			if (executerefundCall.getReturnData().equals("1")) {
				executerefundCall.callService();
			}
			Logger.verifyEquals("5", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(5, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus不变");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_068() {
		Logger.start(false, "支付宝退款RefundStatus状态为1,ymt支付宝商家账户余额不足,RefundStatus状态回到0,隔天时更新RefundBatchNo,JIRACONN-10318 ");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("13");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String rno = YMTDateUtil.getBeforeOrNextDay(-1, "yyyyMMddHHmmssSSS")+1;
			
			pdw.updateRefundNo(rno, mrr.getPaymentId());
			String refundbn = rno;
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil
					.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SELLER_BALANCE_NOT_ENOUGH^false^null");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			Logger.comment("设置交易返回失败");
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);

			executerefundCall.callService();
			Logger.verifyEquals("0", executerefundCall.getReturnData(), "验证返回结果");

			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(0, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus");
			String rbno = list.get(0).getRefundBatchNo().toString();
			Logger.verifyEquals(YMTDateUtil.getSysTime("yyyyMMdd") + 9, rbno.substring(0, 9), "验证隔天退款重新生成的退款单号格式前9位正确");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_069() {
		Logger.start(true, "applepay退款60状态为3提交Mock,成功状态4");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("60");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "3");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回成功");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("Mock", "1");
			executerefundCall.addHeader("MockResult-Trading-Status", "OK");
			executerefundCall.addHeader("MockResult-Trading-Body", "{\"code\":200}");

			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("4", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(4, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus不变");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_070() {
		Logger.start(true, "applepay退款paytype60状态为0提交Mock,成功状态0-1-4");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("60");
			aqb.setPayPrice("6.00");
			String tn = PayGateWayCallService.acquireOrder(aqb).getString("Result");
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, "5.00");
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "0");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回成功");
			// 交易成功后直接修改状态为4完全成功

			// MockResult-ApplePay-respCode 00 消费成功
			// MockResult-ApplePay-tn 12345678 交易号
			// MockResult-ApplePay-respMsg 消费成功[000000] 消费成功消息

			executerefundCall.addHeader("MockResult-ApplePay-respCode", "00");
			executerefundCall.addHeader("MockResult-ApplePay-origRespCode", "00");
			// executerefundCall.addHeader("MockResult-ApplePay-tn",tn);
			executerefundCall.addHeader("MockResult-ApplePay-respMsg", FormatUtil.urlEncode("消费成功[000000]"));

			executerefundCall.addHeader("MockResult-ApplePay-orderId", refundbn);
			executerefundCall.addHeader("MockResult-ApplePay-txnAmt", "500");
			executerefundCall.addHeader("MockResult-ApplePay-currencyCode", "156");
			executerefundCall.addHeader("MockResult-ApplePay-merId", PayGateWayCallService.APPLEPAY_MERID);

			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			// 第一次执行，模拟没有收到退款通知主动查询的情况
			Logger.verifyEquals("1", executerefundCall.getReturnData(), "验证返回结果");
			// 第二次执行
			executerefundCall.callService();
			Logger.verifyEquals("4", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(4, list.get(0).getRefundStatus(), "提交第三方退款成功");
			// pp_payment paystatus 2 CompleteRefundAmt 退款金额
			ppm = this.getPPPayment(aqb);
			Logger.verifyEquals(2, ppm.getPayStatus(), "验证PayStatus");
			Logger.verifyEquals(new BigDecimal(ar.getRefundAmt()).setScale(2), ppm.getCompletedRefundAmt().setScale(2), "验证CompleteRefundAmt");
			List<Map> mock = pdw.selectMockHttpRecordByMockId(mockid);
			for (Map map : mock) {
				// 退款查询发送报文验证
				if (map.get("FunctionName").equals("query")) {
					Map body = FormatUtil.httpStringToMap(map.get("Body").toString());
					// {bizType=000201, orderId=201705110000016615,
					// signature=cXvf9OE4Ang9XQbwRZ0k0mpUFwqaD/LRUOVU8q1lTTfs2crZv0nUxC9m2CedThaSmGngjZuuoOaGNepchRMWg5+/N2sMCE/aRW/JOzCsNw8bbCDfWkMPxtoVxB+WnuAJfFjVnmHLFrW6JC0eMkhkRwvE8jNXkrlthYdtKlEZb84=,
					// txnSubType=00, channelType=08, txnType=00,
					// certId=40220995861346480087409489142384722381,
					// encoding=UTF-8, version=5.0.0, accessType=0,
					// txnTime=20170511112002, merId=308310053994237,
					// currencyCode=156, signMethod=01}
					Logger.debug(body);
					Logger.verifyEquals("000201", body.get("bizType").toString(), "验证bizType固定000201：B2C 网关支付");
					Logger.verifyEquals(refundbn, body.get("orderId").toString(), "验证orderId为RefundBatchNo退款号");
					Logger.verifyEquals("00", body.get("txnSubType").toString(), "验证txnSubType固定00");
					Logger.verifyEquals("08", body.get("channelType").toString(), "验证channelType固定08移动");
					Logger.verifyEquals("00", body.get("txnType").toString(), "验证txnType固定00");
					// 60的id
					// Logger.verifyEquals("40220995861346480087409489142384722381",
					// body.get("certId").toString(), "验证证书id固定");
					// 61的id
					Logger.verifyEquals("73657647234", body.get("certId").toString(), "验证证书id固定");

					// encoding=UTF-8, version=5.0.0, accessType=0,
					// txnTime=20170511112002, merId=308310053994237,
					// currencyCode=156, signMethod=01
					Logger.verifyEquals("UTF-8", body.get("encoding").toString(), "验证encoding");
					Logger.verifyEquals("5.0.0", body.get("version").toString(), "验证version");
					Logger.verifyEquals("0", body.get("accessType").toString(), "验证accessType 商户接入固定填写0：普通商户直连接入");
					Logger.verifyNotNull(body.get("txnTime").toString(), "验证txnTime");
					Logger.verifyEquals(PayGateWayCallService.APPLEPAY_MERID, body.get("merId").toString(), "验证merId");
					Logger.verifyEquals("156", body.get("currencyCode").toString(), "验证currencyCode156人民币");
					Logger.verifyEquals("01", body.get("signMethod").toString(), "验证signMethod非对称签名：01RSA 签名");
				}
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_071() {
		Logger.start(true, "applepay退款paytype60,已经退款回调,成功状态0-1-4");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("60");
			// aqb.setPayPrice("6.00");
			String tn = PayGateWayCallService.acquireOrder(aqb).getString("Result");
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			// 模拟回调
			Logger.comment("模拟applepay退款回调");
			ApplePayRefundNotifyBean applerf = PayGateWayCallService.initApplePayRefundNotifyBean(aqb);
			String send = PayGateWayCallService.ApplePayRefundNotifyToSend(applerf, aqb);

			RefundNotifyCall refundnotifyCall = new RefundNotifyCall(aqb.getPayType());
			refundnotifyCall.setData(send);

			refundnotifyCall.addHeader("Mock", "1");
			String mockid = TestDataManager.getRandomUUID().toString();
			refundnotifyCall.addHeader("MockId", mockid);

			Logger.comment("添加Mock:" + mockid);

			refundnotifyCall.callService();

			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");

			// 交易成功后直接修改状态为4完全成功

			// MockResult-ApplePay-respCode 00 消费成功
			// MockResult-ApplePay-tn 12345678 交易号
			// MockResult-ApplePay-respMsg 消费成功[000000] 消费成功消息

			executerefundCall.addHeader("MockResult-ApplePay-respCode", "00");
			executerefundCall.addHeader("MockResult-ApplePay-origRespCode", "00");
			// executerefundCall.addHeader("MockResult-ApplePay-tn",tn);
			executerefundCall.addHeader("MockResult-ApplePay-respMsg", FormatUtil.urlEncode("消费成功[000000]"));

			executerefundCall.addHeader("MockResult-ApplePay-orderId", refundbn);
			executerefundCall.addHeader("MockResult-ApplePay-txnAmt", "500");
			executerefundCall.addHeader("MockResult-ApplePay-currencyCode", "156");
			executerefundCall.addHeader("MockResult-ApplePay-merId", PayGateWayCallService.APPLEPAY_MERID);

			mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("ok", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(4, list.get(0).getRefundStatus(), "提交第三方退款成功");
			// pp_payment paystatus 2 CompleteRefundAmt 退款金额
			ppm = this.getPPPayment(aqb);
			Logger.verifyEquals(2, ppm.getPayStatus(), "验证PayStatus");
			Logger.verifyEquals(new BigDecimal(ar.getRefundAmt()).setScale(2), ppm.getCompletedRefundAmt().setScale(2), "验证CompleteRefundAmt");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_072() {
		Logger.start(true, "支付宝退款状态为1提交Mock,is_success=T,返回位数9,最后一个处理结果码success,是否充退false,充退结果null,更改退款状态为3退款完成JIRACONN-14665");
		// 支付宝协议变更 出现9位分割状态
		// *
		// is_success=T&result_details=201708290001230527^2017082921001004170290489159^127.00^SUCCESS^false^null$ap.ymt@ymatou.com^2088701734809577^0.70^SUCCESS
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice()
					+ "^SUCCESS^false^null$ap.ymt@ymatou.com^2088701734809577^0.70^SUCCESS");
			Logger.debug(mockResult);
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus3");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_073() {
		Logger.start(true, "支付宝退款状态为1提交Mock,is_success=T,返回位数9,最后一个处理结果码success,是否充退true,充退结果S,更改退款状态为3退款完成");
		// 支付宝协议变更 出现9位分割状态
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice()
					+ "^SUCCESS^true^S$ap.ymt@ymatou.com^2088701734809577^0.70^SUCCESS");
			Logger.debug(mockResult);
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus3");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_074() {
		Logger.start(true, "支付宝退款状态为1提交Mock,is_success=T,返回位数9,处理结果码success是否充退true充退结果P更改退款状态为2退款中");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice()
					+ "^SUCCESS^true^P$ap.ymt@ymatou.com^2088701734809577^0.65^SUCCESS");
			Logger.debug(mockResult);
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("2", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(2, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus2");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_075() {
		Logger.start(true, "支付宝退款状态为1提交Mock,is_success=T,返回位数9,最后一个处理结果码success,是否充退true,充退结果F,更改退款状态为3成功");
		// 支付宝协议变更 出现9位分割状态
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice()
					+ "^SUCCESS^true^F$ap.ymt@ymatou.com^2088701734809577^0.70^SUCCESS");
			Logger.debug(mockResult);
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus3");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_076() {
		Logger.start(true, "支付宝退款状态为1提交Mock,is_success=T,返回位数9,最后一个处理结果码FAIL,是否充退true,充退结果null,更改退款状态为-1失败");
		// 支付宝协议变更 出现9位分割状态
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("10");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice()
					+ "^SUCCESS^true^null$ap.ymt@ymatou.com^2088701734809577^0.70^FAIL");
			Logger.debug(mockResult);
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("-1", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(-1, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus3");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_077() {
		Logger.start(true, "baofu退款70状态为3提交Mock,成功状态4");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("70");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "3");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回成功");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("Mock", "1");
			executerefundCall.addHeader("MockResult-Trading-Status", "OK");
			executerefundCall.addHeader("MockResult-Trading-Body", "{\"code\":200}");

			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("4", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(4, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus不变");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_078() {
		Logger.start(true, "baofu退款paytype70,已经退款回调,成功状态0-1-4");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("70");
			// aqb.setPayPrice("6.00");
			String tn = PayGateWayCallService.acquireOrder(aqb).getString("Result");
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			// 模拟回调
			Logger.comment("模拟baofu退款回调");
			BaoFuRefundNotifyBean baofurefundnbean = PayGateWayCallService.initBaoFuRefundNotifyBean(aqb);
			String baofuexecfund = FormatUtil.beanToGSONString(baofurefundnbean);
			Logger.debug("baofuexecfund:" + baofuexecfund);
			baofuexecfund = "data_content=" + new BaofooSignature().encryptData(baofuexecfund);

			RefundNotifyCall refundnotifyCall = new RefundNotifyCall("70");
			refundnotifyCall.setData(baofuexecfund);

			refundnotifyCall.addHeader("Mock", "1");
			String mockid = TestDataManager.getRandomUUID().toString();
			refundnotifyCall.addHeader("MockId", mockid);

			Logger.comment("添加Mock:" + mockid);

			refundnotifyCall.callService();

			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");

			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-BaofooPay-Result", baofuexecfund);

			mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("ok", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(4, list.get(0).getRefundStatus(), "提交第三方退款成功");
			// pp_payment paystatus 2 CompleteRefundAmt 退款金额
			ppm = this.getPPPayment(aqb);
			Logger.verifyEquals(2, ppm.getPayStatus(), "验证PayStatus");
			Logger.verifyEquals(new BigDecimal(ar.getRefundAmt()).setScale(2), ppm.getCompletedRefundAmt().setScale(2), "验证CompleteRefundAmt");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_079() {
		Logger.start(true, "baofu退款paytype70状态为0提交Mock,成功状态0-5JIRACONN-18383宝付直接退余额");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("70");
			aqb.setPayPrice("6.00");
			String tn = PayGateWayCallService.acquireOrder(aqb).getString("Result");
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, "6.00");
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();

			pdw.updateRefundStatus(refundbn, "0");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			Logger.comment("设置交易返回成功");

			// 交易成功后直接修改状态为4完全成功
			BaoFuRefundNotifyBean baofurn = PayGateWayCallService.initBaoFuRefundNotifyBean(aqb);
			baofurn.setTerminal_id(PayGateWayCallService.BaoFu_TerminalID);
			String baofuexecfund = FormatUtil.beanToGSONString(baofurn);
			Logger.debug("baofuexecfund:" + baofuexecfund);
			baofuexecfund = new BaofooSignature().encryptData(baofuexecfund);
			executerefundCall.addHeader("MockResult-BaofooPay-Result", baofuexecfund);
			executerefundCall.addHeader("Mock", "1");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			// 第一次执行，模拟没有收到退款通知主动查询的情况
			Logger.verifyEquals("5", executerefundCall.getReturnData(), "验证返回结果");

			// //第二次执行
			// executerefundCall.callService();
			// Logger.verifyEquals("4", executerefundCall.getReturnData(),
			// "验证返回结果");
			// list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			// Logger.verifyEquals(5, list.get(0).getRefundStatus(),
			// "提交第三方退款成功");
			// pp_payment paystatus 2 CompleteRefundAmt 退款金额
			// ppm = this.getPPPayment(aqb);
			// Logger.verifyEquals(2, ppm.getPayStatus(), "验证PayStatus");
			// Logger.verifyEquals(Double.valueOf(ar.getRefundAmt()),
			// Double.valueOf(ppm.getCompletedRefundAmt()),
			// "验证CompleteRefundAmt");
			// List<Map> mock = pdw.selectMockHttpRecordByMockId(mockid);
			// Logger.debug(FormatUtil.beanToGSONString(mock));
			// for (Map map : mock) {
			// //退款查询发送报文验证
			// if(map.get("FunctionName").equals("refundQuery")){
			// Map body=FormatUtil.httpStringToMap(map.get("Body").toString());
			// //"member_id=1192439&txn_type=331&data_type=json&txn_sub_type=10&data_content=042585f85ca88a849691cd36c3d9236695bf5d100e9b9924764588081c00500f014a36f7428e1cb4e27a3ff72a15942268123c4fb4b3f3f63375be32cc5270d9e36d544c9aa8e9e7e81bbf8f6cf6750b6eb0a020e2ce2fc990ab60b8e302e671199e9ad280c48f694ed01c9afe876930695b7902ca5441f0f4ded880c0d762a0ce2d37895c33495700751824a2345aa2263ffa32280c8e829e7886561cb101102b6a5d9e15a1dbe2d43653173eb23d76316347592c5beb144e00ab54d451d791ee978699a5597474a9e92baf7a72d4e8de1c9d4dd502ea2224e2d77591252efe1951882751648b0fc06318eb8a20f228b8df02c89a177bd5715a4f5beab9d5f3&version=4.0.0.0&terminal_id=36657"
			// Logger.debug(body);
			// Logger.verifyEquals("BaofooPay", map.get("AppId").toString(),
			// "验证AppId");
			// Logger.verifyEquals("200", map.get("ResponseStatus").toString(),
			// "验证ResponseStatus");
			// Logger.verifyEquals(PayGateWayCallService.BaoFu_MERID,
			// body.get("member_id").toString(), "验证member_id");
			// Logger.verifyEquals("4.0.0.0", body.get("version").toString(),
			// "验证version");
			// }
			// }
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_080() {
		Logger.start(true, "招行退款paytype50状态为0提交Mock,返回退款失败MSS3804,退回余额");
		try {
			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("50");
			Account account = new AccountWapper().selectAccountInfoByUserId(Integer.valueOf(aqb.getUserId())).get(0);
			Logger.comment("设置userid账户余额");
			new AccountCallServiceV2().resetAccount(account.getAccountId().toString(), new BigDecimal(0), new BigDecimal(0));

			aqb.setPayPrice("6.00");
			PayGateWayCallService.acquireOrder(aqb);
			String discountAmt = "1.00";
			PayGateWayCallService.notifyCall50(aqb, discountAmt);

			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, "5.00");
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "0");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());

			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回成功");
			// {"charset": "UTF-8","rspData": {"rspCode": "MSS3804","rspMsg":
			// "MSS3804.退款失败.WWO0289 - 您的银行卡暂不支持银联跨行支付业务，请向您的发卡行反映 [DJ113939]"
			// },"signType": "SHA-256","version": "1.0"}
			executerefundCall.addHeader("MockResult-Cmb-rspCode", "MSS3804");
			executerefundCall.addHeader("MockResult-Cmb-rspMsg", FormatUtil.urlEncode("MSS3804.退款失败.WWO0289 - 您的银行卡暂不支持银联跨行支付业务，请向您的发卡行反映"));
			// executerefundCall.addHeader("MockResult-Cmb-cardType", "02");
			// executerefundCall.addHeader("MockResult-Cmb-orderAmount",
			// "6.00");
			// executerefundCall.addHeader("MockResult-Cmb-discountAmount",
			// "0.00");
			// executerefundCall.addHeader("MockResult-Cmb-orderStatus", "0");
			// executerefundCall.addHeader("MockResult-Cmb-date",
			// YMTDateUtil.getSysTime("yyyyMMdd"));
			// executerefundCall.addHeader("MockResult-Cmb-orderNo",
			// ppm.getPaymentId());

			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("5", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(5, list.get(0).getRefundStatus(), "再次调用退到余额");

			// alist=new
			// AccountWapper().selectAccountInfo(account.getAccountId().toString());
			// Logger.debug("退款后:"+FormatUtil.beanToGSONString(alist));
			// Logger.verifyEquals(new BigDecimal(5).setScale(2), new
			// BigDecimal(alist.get(0).get("fAvailAmount").toString()).setScale(2),
			// "余额");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_081() {
		Logger.start(false, "支付宝退款RefundStatus状态为1,ymt支付宝商家账户余额不足,RefundStatus状态回到0,新协议");
		try {
			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("13");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice()
					+ "^SELLER_BALANCE_NOT_ENOUGH^false^null$ap.ymt@ymatou.com^2088701734809577^0.00^CHECK_VALID_SUCCESS");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			Logger.comment("设置交易返回失败");
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("0", executerefundCall.getReturnData(), "验证返回结果");

			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(0, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_082() {
		Logger.start(false, "支付宝退款RefundStatus状态为1,BUYER_ERROR导致退款失败");
		try {
			// 0-1- -5 -5
			// is_success=T&result_details=201709100001248579^2017081821001004870206632988^35.00^BUYER_ERROR^false^null$ap.ymt@ymatou.com^2088701734809577^0.00^CHECK_VALID_SUCCESS
			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("13");
			Account account = new AccountWapper().selectAccountInfoByUserId(Integer.valueOf(aqb.getUserId())).get(0);
			Logger.comment("设置userid账户余额");
			new AccountCallServiceV2().resetAccount(account.getAccountId().toString(), new BigDecimal(0), new BigDecimal(0));
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice()
					+ "^BUYER_ERROR^false^null$ap.ymt@ymatou.com^2088701734809577^0.00^CHECK_VALID_SUCCESS");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			Logger.comment("设置交易返回失败");
			executerefundCall.addHeader("MockResult-Trading-Status", "OK");
			executerefundCall.addHeader("MockResult-Trading-Body", "{\"code\":200}");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("5", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(5, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus");

			List<AccountEntry> alist = new AccountWapper().selectAccountEntryByOriginalNo(ar.getTradeNo());
			// Logger.debug(FormatUtil.beanToGSONString(alist));
			Logger.verifyEquals(new BigDecimal(aqb.getPayPrice()).setScale(2), alist.get(0).getAvailAmount().setScale(2), "余额");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_083() {
		Logger.start(true, "applepay退款paytype60,respCode=34状态0_JIRACONN-15218");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("60");
			// aqb.setPayPrice("6.00");
			String tn = PayGateWayCallService.acquireOrder(aqb).getString("Result");
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			// 模拟回调
			Logger.comment("模拟applepay退款回调");
			ApplePayRefundNotifyBean applerf = PayGateWayCallService.initApplePayRefundNotifyBean(aqb);
			String send = PayGateWayCallService.ApplePayRefundNotifyToSend(applerf, aqb);

			RefundNotifyCall refundnotifyCall = new RefundNotifyCall(aqb.getPayType());
			refundnotifyCall.setData(send);

			refundnotifyCall.addHeader("Mock", "1");
			String mockid = TestDataManager.getRandomUUID().toString();
			refundnotifyCall.addHeader("MockId", mockid);

			Logger.comment("添加Mock:" + mockid);

			refundnotifyCall.callService();

			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");

			executerefundCall.addHeader("MockResult-ApplePay-respCode", "34");
			executerefundCall.addHeader("MockResult-ApplePay-origRespCode", "00");
			executerefundCall.addHeader("MockResult-ApplePay-respMsg", FormatUtil.urlEncode("查无此交易[2600000]"));

			executerefundCall.addHeader("MockResult-ApplePay-orderId", refundbn);
			executerefundCall.addHeader("MockResult-ApplePay-txnAmt", "500");
			executerefundCall.addHeader("MockResult-ApplePay-currencyCode", "156");
			executerefundCall.addHeader("MockResult-ApplePay-merId", PayGateWayCallService.APPLEPAY_MERID);

			mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("0", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(0, list.get(0).getRefundStatus(), "提交第三方退款成功");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	// failed 宝付JIRACONN-18383宝付直接退余额
	public void Tc_ExecuteRefund_084() {
		Logger.start(true, "baofu退款paytype70状态为0提交Mock商户余额不足,拒绝退款,退回初始状态0");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("70");
			aqb.setPayPrice("6.00");
			String tn = PayGateWayCallService.acquireOrder(aqb).getString("Result");
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, "6.00");
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();

			pdw.updateRefundStatus(refundbn, "0");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);

			// 更新refundno
			pdw.updateRefundNo(refundbn.replaceFirst(YMTDateUtil.getSysTime("yyyyMMdd"), String.valueOf((Long.valueOf(YMTDateUtil.getSysTime("yyyyMMdd")) - 1))),
					ppm.getPaymentId());

			// {"member_id":"1192439","data_type":"json","resp_code":"BF00308","txn_sub_type":"10","resp_msg":"交易失败：拒绝退款，拒绝理由：账户余额不足，退款失败！请充值后重新发起。","version":"4.0.0.0","refund_order_no":"201710040001281994","terminal_id":"36657"}
			BaoFuRefundNotifyBean baofurn = PayGateWayCallService.initBaoFuRefundNotifyBean(aqb);
			baofurn.setTerminal_id(PayGateWayCallService.BaoFu_TerminalID);
			baofurn.setResp_code("BF00308");
			baofurn.setResp_msg("交易失败：拒绝退款，拒绝理由：账户余额不足，退款失败！请充值后重新发起。");
			String baofuexecfund = FormatUtil.beanToGSONString(baofurn);
			Logger.debug("baofuexecfund:" + baofuexecfund);
			baofuexecfund = new BaofooSignature().encryptData(baofuexecfund);
			executerefundCall.addHeader("MockResult-BaofooPay-Result", baofuexecfund);
			executerefundCall.addHeader("Mock", "1");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			// 第一次执行,失败
			Logger.verifyEquals("-1", executerefundCall.getReturnData(), "验证返回结果");
			// 第二次再查 发现余额不足 变成0
			executerefundCall.callService();
			Logger.verifyEquals("0", executerefundCall.getReturnData(), "验证返回结果");
			ppm = this.getPPPayment(aqb);
			Logger.verifyEquals(1, ppm.getPayStatus(), "验证PayStatus");

			List<Map> mock = pdw.selectMockHttpRecordByMockId(mockid);
			Logger.debug(FormatUtil.beanToGSONString(mock));
			for (Map map : mock) {
				// 退款查询发送报文验证
				if (map.get("FunctionName").equals("refundQuery")) {
					Map body = FormatUtil.httpStringToMap(map.get("Body").toString());
					// "member_id=1192439&txn_type=331&data_type=json&txn_sub_type=10&data_content=042585f85ca88a849691cd36c3d9236695bf5d100e9b9924764588081c00500f014a36f7428e1cb4e27a3ff72a15942268123c4fb4b3f3f63375be32cc5270d9e36d544c9aa8e9e7e81bbf8f6cf6750b6eb0a020e2ce2fc990ab60b8e302e671199e9ad280c48f694ed01c9afe876930695b7902ca5441f0f4ded880c0d762a0ce2d37895c33495700751824a2345aa2263ffa32280c8e829e7886561cb101102b6a5d9e15a1dbe2d43653173eb23d76316347592c5beb144e00ab54d451d791ee978699a5597474a9e92baf7a72d4e8de1c9d4dd502ea2224e2d77591252efe1951882751648b0fc06318eb8a20f228b8df02c89a177bd5715a4f5beab9d5f3&version=4.0.0.0&terminal_id=36657"
					Logger.debug(body);
					Logger.verifyEquals("BaofooPay", map.get("AppId").toString(), "验证AppId");
					Logger.verifyEquals("200", map.get("ResponseStatus").toString(), "验证ResponseStatus");
					Logger.verifyEquals(PayGateWayCallService.BaoFu_MERID, body.get("member_id").toString(), "验证member_id");
					Logger.verifyEquals("4.0.0.0", body.get("version").toString(), "验证version");
				}
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_085() {
		Logger.start(true, "支付宝paytype9退款状态为1提交Mock,is_success=T,返回位数4,处理结果码success,更改退款状态为3退款完成");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("9");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			String mockResult = FormatUtil.urlEncode("is_success=T&result_details=" + refundbn + "^" + ppm.getInstitutionPaymentId() + "^" + aqb.getPayPrice() + "^SUCCESS");
			executerefundCall.addHeader("MockResult-AliPay-Result", mockResult);
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");

			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款成功RefundStatus");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P2.class })
	@TestCase
	public void Tc_ExecuteRefund_086() {
		Logger.start(true, "微信APP小程序退款状态为1提交Mock,refund_status为SUCCESS,更改退款状态为3退款完成");
		try {

			AcquireOrderBean aqb = PayGateWayCallService.initAcquireOrder("17");
			PayGateWayCallService.acquireOrder(aqb);
			PayGateWayCallService.notifyCall(aqb);
			AcquireRefundBean ar = PayGateWayCallService.AcquireRefund(aqb, aqb.getPayPrice());
			PayGateWayCallService.approveRefund(ar.getTradeNo());
			Logger.comment("查询部分退款单号");
			MPayment ppm = this.getPPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			String refundbn = mrr.getRefundBatchNo().toString();
			String refundid = mrr.getRefundId().toString();
			pdw.updateRefundStatus(refundbn, "1");
			List<MRefund> list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			executerefundBean.setRefundId(refundid);
			executerefundCall.setData(executerefundBean);
			executerefundCall.addHeader("Mock", "1");
			Logger.comment("设置交易返回失败");
			// 交易成功后直接修改状态为4完全成功
			executerefundCall.addHeader("MockResult-Trading-Status", "FAILD");
			executerefundCall.addHeader("MockResult-WeiXin-refund_status", "SUCCESS");
			executerefundCall.addHeader("MockResult-WeiXin-total_fee", new BigDecimal(aqb.getPayPrice()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-refund_fee", new BigDecimal(ar.getRefundAmt()).multiply(BigDecimal.valueOf(100)).setScale(0).toString());
			executerefundCall.addHeader("MockResult-WeiXin-out_trade_no",ppm.getPaymentId());
			String mockid = TestDataManager.getRandomUUID().toString();
			executerefundCall.addHeader("MockId", mockid);
			executerefundCall.callService();
			Logger.verifyEquals("3", executerefundCall.getReturnData(), "验证返回结果");
			list = pdw.selectRefundRequestByTraceId(ar.getRefundNo());
			Logger.verifyEquals(3, list.get(0).getRefundStatus(), "提交第三方退款失败RefundStatus3");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	private void verifyMock(String mockid) throws Exception {
		List<Map> mock = pdw.selectMockHttpRecordByMockId(mockid);
		Logger.debug(mock);
	}
}